package org.fireflow2.designer.eclipse.commands.connection;

import org.eclipse.draw2d.AbsoluteBendpoint;
import org.eclipse.draw2d.Bendpoint;
import org.eclipse.draw2d.geometry.Point;
import org.eclipse.gef.commands.Command;
import org.fireflow2.designer.eclipse.modelwrapper.ConnectorWrapper;

public class MoveBendPointCommand extends Command {
	ConnectorWrapper model;
	Bendpoint newPoint;
	Bendpoint oldPoint;
	int index;
	
//	Point referencePoint;

	public MoveBendPointCommand(ConnectorWrapper model
			, Point point,int index) {
		super();
		this.model = model;
		this.newPoint = new AbsoluteBendpoint(point);
		this.index = index;
	}
	
//	public Point getReferencePoint() {
//		return referencePoint;
//	}
//
//	public void setReferencePoint(Point referencePoint) {
//		this.referencePoint = referencePoint;
//	}

	@Override
	public void execute() {
		oldPoint = model.setConstraint(index, newPoint);
	}

	@Override
	public void undo() {
		model.setConstraint(index, oldPoint);
	}
	
	public void redo(){
		model.setConstraint(index, newPoint);
	}	
}
